package pl.icn.hurtownia.mappings;

import org.dozer.DozerBeanMapper;
import org.dozer.Mapper;
import org.dozer.MappingException;

/**
 * Dozer mapujący obiekty hurtowni
 */
public class HurtowniaMapper implements Mapper {

	/** Mapper */
	private DozerBeanMapper mapper;
	
	@Override
	public <T> T map(Object source, Class<T> destinationClass) throws MappingException {
		if (source == null) {
			return null;
		}
		T dest = mapper.map(source, destinationClass);
		return dest;
	}

	@Override
	public void map(Object source, Object destination) throws MappingException {
		if (source == null) {
			return;
		}
		mapper.map(source, destination);
	}

	@Override
	public <T> T map(Object source, Class<T> destinationClass, String mapId) throws MappingException {
		if (source == null) {
			return null;
		}
		T dest = mapper.map(source, destinationClass, mapId);
		return dest;
	}

	@Override
	public void map(Object source, Object destination, String mapId) throws MappingException {
		if (source == null) {
			return;
		}
		mapper.map(source, destination, mapId);
	}

	/**
	 * Przypisuje nową wartość polu <code>mapper</code>.
	 * 
	 * @param mapper nowa wartość pola mapper
	 */
	public void setMapper(DozerBeanMapper mapper) {
		this.mapper = mapper;
	}
	
}
